#include <stdio.h>
#define BASE_TIME 40  // 40 小时以上算加班
#define OVER_TIME 1.5 // 40 小时以上算1.5倍时间
#define RATE1 0.15    // 前 300 美元税率
#define RATE2 0.20    // 续 150 美元税率
#define RATE3 0.25    // 余下税率
void work(float base_pay, float time);
float get_time();
int main(void)
{
    float time;
    float base_pay;
    int num = 0; // 序号

    while (num != 'q')
    {
        printf("****************************************\n");
        printf("a) $8.75/hr\t\tb) $9.33/hr\nc) $10.00/hr\t\td) $11.20/hr\nq) quit\n");
        printf("****************************************\n");
        num = getchar();
        if (num == '\n')
            continue;
        switch (num)
        {
        case 'a':
            base_pay = 8.75;
            time = get_time();
            work(base_pay, time);
            break;
        case 'b':
            base_pay = 9.33;
            time = get_time();
            work(base_pay, time);
            break;
        case 'c':
            base_pay = 10.00;
            time = get_time();
            work(base_pay, time);
            break;
        case 'd':
            base_pay = 11.20;
            time = get_time();
            work(base_pay, time);
            break;
        case 'q':
            break;
        default:
            printf("请输入正确的选项\n");
        }
    }
    printf("Done!\n");

    return 0;
}

void work(float base_pay, float time)
{
    float sum;
    float tax;
    float salary;

    if (time <= BASE_TIME)
        sum = 10 * time;
    else
        sum = base_pay * BASE_TIME + (time - BASE_TIME) * OVER_TIME * base_pay;
    if (sum <= 300)
        tax = 300 * RATE1;
    else if (sum < 300 + 150)
        tax = 300 * RATE1 + (sum - 300) * RATE2;
    else
        tax = 300 * RATE1 + 150 * RATE2 + (sum - 300 - 150) * RATE3;
    salary = sum - tax;
    printf("工资总额:%.2f 税金:%.2f 净收入:%.2f\n", sum, tax, salary);
    printf("\n");
}

float get_time()
{
    float time;
    printf("输入工作的小时数：");
    scanf("%f", &time);
    return time;
}